package com.expense.app.admin.controller;

import com.expense.app.admin.annotation.IgnoreAuth;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.Min;
import com.expense.common.util.Result;
import com.expense.app.admin.services.bmw.BmwSceneServ;
import com.expense.app.admin.model.params.bmw.bmwScene.BmwSceneParam;
import com.expense.app.admin.model.params.bmw.bmwScene.BmwSceneListParam;

/*
*
* gen controller 2019-11-12
*/
@Validated
@RestController
@RequestMapping("/bmw/scene")
public class BmwSceneCtrl {

    @Autowired
    BmwSceneServ bmwSceneServ;

    @IgnoreAuth
    @GetMapping("/web/list")
    public Result findWebList(@Validated BmwSceneListParam param) {
        return Result.success(bmwSceneServ.findList(param));
    }

    @GetMapping("/list")
    public Result findList(@Validated BmwSceneListParam param) {
        return Result.success(bmwSceneServ.findList(param));
    }

    @GetMapping(value = "/{id}")
    public Result findDetail (@PathVariable @Min(1) Long id) {
        return Result.success(bmwSceneServ.findDetail(id));
    }

    @PostMapping(value = "/save")
    public Result saveOne(@Validated @RequestBody BmwSceneParam param) {
        return Result.success(bmwSceneServ.saveOne(param));
    }

    @PutMapping(value = "/update")
    public Result update(@Validated @RequestBody BmwSceneParam param) {
        return Result.success(bmwSceneServ.saveOne(param));
    }

    @DeleteMapping(value = "/{id}")
    public Result deleteOne(@PathVariable @Min(1) Long id) {
        return Result.success(bmwSceneServ.deleteOne(id), true);
    }
}
